<template>
  <div>
  <h1 style="margin-left:260px;"><span>登录</span></h1>
  <el-row style="margin-left:220px;">
  <el-col :span="8">
	<el-form :model="dyForm" ref="dyForm" label-width="100px" class="demo-dynamic">
  <el-form-item
    prop="name"
    label="用户名"
    :rules="[
      { required: true, message: '请输入用户名', trigger: 'blur' }
    ]"
  >
    <el-input v-model="dyForm.name"></el-input>
  </el-form-item>
  <el-form-item
    prop="pass"
    label="密码"
    :rules="[
      { required: true, message: '请输入密码', trigger: 'blur' }
    ]"
  >
    <el-input v-model="dyForm.pass" type="password"></el-input>
  </el-form-item>
  <el-form-item>
  <el-button type="primary" @click="onLogin(dyForm)">登录</el-button>
  <el-button>注册</el-button>
  </el-form-item>
  </el-form>
  </el-col>
  </el-row>
  </div>
</template>

<script>
import axios from 'axios'
export default {
 	components: {
 		
 	},
 	data() {
      return {
        dyForm:{
          name:'',
          pass:''
      }
    }
  },
  methods:{
      
      onLogin(dyForm){
        let vm = this;
        axios.get('/api/login',{
        params:{
          name:dyForm.name,
          password:dyForm.pass
        }
      }).then(function(r){
        if (r.data.errcode != 0) {
            return ;
        }
        console.log(JSON.stringify(r));
        vm.$router.push('/');
      }).catch(e=>{
        console.log(e);
      });
    }
  }

}
</script>
<style>
	

</style>